window.Runtime= new function () 
{
        /**
         * @private
         * A reference to the global object
         * @type {Object}
         * @see Runtime#getGlobal
         */
    var GLOBAL= (function(){return this})()
        
        /**
         * @private
         * A static reference to the undefined value. The word 'undefined' is
         * not a keyword in JavaScript and can easily be overwritten by a 
         * mistyped comparison suchs as undefined = false.
         * @type {undefined}
         */
    ,   UNDEFINED= void(0)
   

    this.constructor.implement
    (
        {
            /**
             * Declare a class or object and its namespace. The namespace
             * object hierarchy will be generated, and will refer to the
             * object arguments
             * 
             * @param {String} namespace    A canonical class or object name
             * @param {Object} object       A class or object
             * @param {Object} [scope]      An object to use as the namespace root
             * @return {Object}
             */
            declare: function (namespace, object, scope) 
            {
                return this.namespace(namespace, object, scope);
            }

            /**
             * Find an object declared in an object hierarchy such as a
             * namespace or nested object. If the object was not found, value of
             * the returned objects exists property is false. The exists property
             * of the returned value is true if and only if the value was found.
             * 
             *The
             * returned value avoids the issue of using sentinels to disambiguate
             * unfound objects and null and undefined values by returning
             * a record object instead. The exists property will tell you wehterh
             * the last identifier was found in an object hierarchy, or not,
             * and the value property will refer to the located value, or
             * undefined.
             * 
             * @param {Object} canonicalName The canonical name of an object
             * @param {Object} scope  The start scope in which to begin the search
             * @return {{exists: Boolean, value}} The result of the search
             */
        ,   find: function (canonicalName, scope) 
            {
                var identifiers= canonicalName.split('.')
                ,   identifier;
                
                scope= scope || GLOBAL;
                
                for (var i= 0, n= identifiers.length; i < n; i++) 
                {
                    identifier= identifiers[i];
                    if (identifier in scope) 
                    {
                        scope= scope[identifier];
                    }
                    else 
                    {
                        return {
                            exists: false
                        ,   value: UNDEFINED
                        }
                    }
                }
                
                return {
                    exists: true
                ,   value: scope
                };
            }
            
            /**
             * Declare a namespace.
             * 
             * @param {String} name        The namespaces canonical name.
             * @param {Object} [object]    An optional value to put as the last node in the namespace
             * @param {Object} [startNode] An optional object scope in which to declare the namespace
             * @return {Object}    A reference to the last namespace node
             */
        ,   namespace: function (name, object, startNode) 
            {
                var nodes= String(name).split('.')
                ,   node= startNode || GLOBAL
                ,   lastNode
                ,   nodeName
                ,   i = 0
                ,   n = nodes.length
                ;
                
                while (i < n) 
                {
                    lastNode= node;
                    nodeName= nodes[i++];
                    node= (null == node[nodeName]) ? (node[nodeName] = {}) : node[nodeName];
                }
                
                return object ? (lastNode[nodeName] = object) : node;
            }
            
            /**
             * Get a reference to the global scope.
             * @return {Object}
             */
        ,   getGlobal: function () 
            {
                return GLOBAL;
            }
        }
    )
};
